using System;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using log4net;
using FSS.DAL.DBManagers;
using FSS.BLL.Entities;
using System.IO;
namespace FSS.BLL.Services
{
    #region IBackupFileService

    /// <summary>
    /// ActivityLogService object for Ibatis mapped table 'ActivityLog'.
    /// </summary>
    public class IBackupFileService : BaseSqlMapDao
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(IBackupFileService).Name);
        /// <summary>
        /// add new Bank to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Backup(BackupFileEntity objE)
        {
            try
            {
                ExecuteInsert("BackupFileBackup", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                return 0;
            }
        }
        public int Restore(BackupFileEntity objE)
        {
            try
            {
                ExecuteInsert("BackupFileRestore", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                return 0;
            }
        }
        /// <summary>
        /// Delete the backup file
        /// </summary>
        /// <param name="fileName">Backup file name</param>
        public bool DeleteBackup(string fileName)
        {
            try
            {
                if (File.Exists(fileName))
                    File.Delete(fileName);
                return true;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                return false;
            }
        }
    }
    #endregion
}
